package com.nai365.nart.operation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nai365.nart.operation.entity.DrawLotsSignUp;
import com.nai365.nart.operation.mapper.DrawLotsSignUpMapper;
import com.nai365.nart.operation.service.DrawLotsSignUpService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DrawLotsSignUpServiceImpl extends ServiceImpl<DrawLotsSignUpMapper, DrawLotsSignUp> implements DrawLotsSignUpService {
	@Override
	public Boolean saveDrawLotsSignUp(DrawLotsSignUp drawLotsSignUp) {
		return this.save(drawLotsSignUp);
	}

	@Override
	public List<DrawLotsSignUp> findUserSignUpById(Long userId) {
		LambdaQueryWrapper<DrawLotsSignUp> drawLotsSignUpLambdaQueryWrapper = new LambdaQueryWrapper<>();
		drawLotsSignUpLambdaQueryWrapper.eq(DrawLotsSignUp::getUserId,userId);
		return this.list(drawLotsSignUpLambdaQueryWrapper);
	}

	@Override
	public DrawLotsSignUp findUserSignUp(Long userId, Long goodsId) {
		LambdaQueryWrapper<DrawLotsSignUp> drawLotsSignUpLambdaQueryWrapper = new LambdaQueryWrapper<>();
		drawLotsSignUpLambdaQueryWrapper.eq(DrawLotsSignUp::getUserId,userId);
		drawLotsSignUpLambdaQueryWrapper.eq(DrawLotsSignUp::getGoodsId,goodsId);
		return  this.getOne(drawLotsSignUpLambdaQueryWrapper);
	}

	@Override
	public List<DrawLotsSignUp> findUserSignUpBySerialNumber(Integer serialNumber) {
		LambdaQueryWrapper<DrawLotsSignUp> drawLotsSignUpLambdaQueryWrapper = new LambdaQueryWrapper<>();
		drawLotsSignUpLambdaQueryWrapper.eq(DrawLotsSignUp::getSerialNumber,serialNumber);
		return this.list(drawLotsSignUpLambdaQueryWrapper);
	}

	@Override
	public List<DrawLotsSignUp> findUserSignUpByGoodsId(Long goodsId) {
		LambdaQueryWrapper<DrawLotsSignUp> drawLotsSignUpLambdaQueryWrapper = new LambdaQueryWrapper<>();
		drawLotsSignUpLambdaQueryWrapper.eq(DrawLotsSignUp::getGoodsId,goodsId);
		return this.list(drawLotsSignUpLambdaQueryWrapper);
	}
}
